Repository navigation
feat(quote): add QuoteTransport to serve quote pull APIs over HTTP - #604
Open
hogan-yuan wants to merge 3 commits into
Open
hogan-yuan wants to merge 3 commits into
hogan-yuan wants to merge 3 commits into
Conversation
Add `Config::quote_transport(QuoteTransport::{WebSocket, Http})` (env
`LONGBRIDGE_QUOTE_TRANSPORT=ws|http`, default WebSocket). With `Http`, the
19 `QuoteContext` pull APIs that have a REST equivalent are sent as
`POST /quote/*` instead of over the quote WebSocket, so a process that only
pulls data never opens a WebSocket connection. Method signatures and return
types are unchanged: the request is the same prost message serialised as
JSON, and the gateway proto-JSON response is decoded back into the same
prost message by a lenient deserializer (int64-as-string, omitted/null
fields, camelCase keys), so the existing conversions are reused.
Results are aligned with the WebSocket, including US overnight data, which
the gateway always returns over REST but the WebSocket only returns when
`enable_overnight` is set: on the HTTP path the SDK strips
`overnight_quote`, filters overnight intraday lines, drops overnight
candlesticks and tops up count/range-capped candlestick windows with offset
queries (`quote::overnight`, unit-tested).
Expose the option in the C, C++, Java, Node.js and Python layers, mirroring
`PushCandlestickMode`, and add `examples/rust/quote_http_compare`, which
calls every pull API over both transports and diffs the results.
- refill: once a page yields no usable bar the cursor is inside the contiguous 20:00-04:00 overnight block; fetch a full page to jump it instead of inching through (regression tests for both directions) - gate overnight dropping on the same US-equity predicate everywhere and compute the window target in one place (CandlestickWindow / window_target, unit-tested) - CHANGELOG: split the entry, list the top-up endpoint, error-variant, 429-retry and overnight-session caveats; 20 methods / 19 commands - drop the undocumented "websocket" env alias; ignore only .env/.env.local; revert unrelated example reformatting
hogan-yuan
force-pushed
the
feat/quote-http-transport
branch
from
October 10, 2026 10:28
ef2a9d6 to
7a24f57
Compare
- only drop overnight candlesticks for TradeSessions::All queries, so a page is either left untouched or dropped and topped up (matches Go) - a date-range page shorter than the request cap is never treated as capped; avoids a wasted top-up request for weekend/holiday starts - warn when the top-up returns fewer candlesticks than the WebSocket would - clear overnight_quote only for US equities, like intraday/candlesticks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
Config::quote_transport(QuoteTransport::{WebSocket, Http})(envLONGBRIDGE_QUOTE_TRANSPORT=ws|http, defaultWebSocket). WithHttp, the 19QuoteContextpull APIs that have a REST equivalent (static_info,quote,option_quote,warrant_quote,depth,brokers,participants,trades,intraday,candlesticks,history_candlesticks_by_offset/by_date,option_chain_expiry_date_list,warrant_issuers,warrant_list,trading_session,trading_days,capital_flow,capital_distribution,calc_indexes) go overPOST /quote/*instead of the quote WebSocket. A process that only pulls data never opens a WebSocket connection. Public method signatures and return types are unchanged.The option is exposed in all six layers (Rust, C, C++, Java, Node.js, Python), mirroring
PushCandlestickMode.Why
longbridge/longbridge-mcp#162 re-implemented every quote tool on top of the REST endpoints inside the MCP (per-tool JSON reshaping) to get rid of its per-user WebSocket pool. That logic belongs in the SDK: one switch in
QuoteContext::request, and every SDK consumer (MCP, CLI, …) gets it with identical types.How
rust/src/quote/cmd_code.rs::http_pathmaps WS command codes to REST paths;QuoteContext::request/request_without_bodybranch on the transport. The request is the same prost message serialised as JSON (nulls stripped); the response is decoded into the same prost message byrust/src/quote/http_json.rs, a lenient serde deserializer (int64-as-string, omitted/null→ default, camelCase keys, unknown fields ignored), so all existingTryFromconversions are reused.rust/src/quote/overnight.rsaligns the one known server-side difference: REST always returns US overnight data and has no opt-out, while the WS only returns it whenenable_overnightis set. On the HTTP path (and only there) the SDK stripsovernight_quote, filters overnight intraday lines for US equities, dropsOvernightTradecandlesticks and tops up count/range-capped candlestick windows with offset queries (≤1000 per request, ≤8 rounds). The WebSocket path is byte-identical tomain.examples/rust/quote_http_comparecalls every pull API over both transports and diffs the results.Verification
Report with every call's request/response and WS-vs-HTTP diff (canary + production, overnight on/off): https://v.longbridge-inc.com/p/zhanghong.yuan/quote-http-传输验证
/quote/*replicas serve different data).cargo test -p longbridge --lib quote::14/14;cargo clippy --all --all-featuresadds no warnings;cargo +nightly fmt --all.Known gateway gaps (not fixable in the SDK)
500 internal server errorinstead of passing the code through (WS:301600,301604,301607). Callers that branch on error codes will not work over HTTP until this is fixed./quote/*data is not consistent across replicas (see report).🤖 Generated with Claude Code